<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        let ma = new Map([
            ['name', '胡歌'],
            ['age', 20],
            [{ a: 2 }, 'pyy']
        ])
        console.log(ma);

        let a = { a: 1 }
        let ma1 = new Map()
        ma1.set('name', '胡歌')
        ma1.set('age', 20)
        ma1.set(a, 'pyy')

        // ma1.set({ a: 1 }, 'pyy')
        console.log(ma1);


        for (const i of ma1) {
            console.log(i);
        }

        console.log([...ma1]);

        // size set get delete  has

        console.log(ma1.get('name'));
        console.log(ma1.get(a));//获取
        console.log(ma1.has(a));//判断有没有
        console.log(ma1.size);//



        
        console.log('-----keys()遍历返回键-----');

        for (let i of ma1.keys()) {
            console.log(i);
        }

        console.log('-----values()遍历返回值-----');

        for (let i of ma1.values()) {
            console.log(i);
        }
        
        console.log('------entries()遍历返回键值-----');
        for (let [i,itme] of ma1.entries()) {
            console.log(i,itme);
        }
        // 和上面一样效果
        for (let [i,itme] of ma1) {
            console.log(i,itme);
        }

    </script>
</body>

</html>